package com.zhang.crm.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhang.crm.constant.Constants;
import com.zhang.crm.mapper.TActivityRemarkmapper;
import com.zhang.crm.pojo.TActivityRemark;
import com.zhang.crm.service.ActivityRemarkService;
import com.zhang.crm.util.UserUtil;
import jakarta.annotation.Resource;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;


@Service
public class ActivityRemarkServiceImpl implements ActivityRemarkService {
    @Resource
    private TActivityRemarkmapper tActivityRemarkmapper;
    @Override
    public PageInfo<TActivityRemark> getRemarkById(Integer activityId, Integer current) {
        PageHelper.startPage(current, Constants.PAGE_DATA_SIZE);
        List<TActivityRemark> tActivityRemarks = tActivityRemarkmapper.selectRemarkByActivityId(activityId);
        PageInfo<TActivityRemark> pageInfo = new PageInfo<>(tActivityRemarks);
        return pageInfo;
    }

    @Override
    @Transactional
    public Boolean addRemark(TActivityRemark tActivityRemark) {
        tActivityRemark.setCreateBy(UserUtil.getUserInfo().getId());
        tActivityRemark.setCreateTime(new Date());
        //默认正常
        tActivityRemark.setDeleted(0);
        int i = tActivityRemarkmapper.insertSelective(tActivityRemark);
        return i > 0 ? true : false;
    }


}
